package com.surveillance.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.ManyToOne;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.OneToOne;

@Entity
@Table(name = "concours", uniqueConstraints = { @UniqueConstraint(columnNames = { "id" }) })
public class Concours extends  BaseEntity {
	@Column(name = "DATE_DBUT", nullable = false)
	private Date dateDebut;
	@Column(name = "DATE_FIN", nullable = false)
	private Date dateFin;
	@Column(name = "TYPE", nullable = false)
	private String type;
	@ManyToOne(fetch = FetchType.EAGER, targetEntity = Agenda.class)
	private Agenda agenda;
	@OneToMany(fetch = FetchType.EAGER, targetEntity = Salle.class)
	Set<Salle> salles = new HashSet<Salle>(0);
	@OneToMany(fetch = FetchType.EAGER, targetEntity = Surveillant.class)
	private Set<Surveillant> surveillants = new HashSet<Surveillant>(0);

	public Concours() {

	}

	public Concours(Long id, Date dateDebut, Date dateFin, String type,
			Agenda agenda, Set<Salle> salles, Set<Surveillant> surveillants) {
		super();
		this.id = id;
		this.dateDebut = dateDebut;
		this.dateFin = dateFin;
		this.type = type;
		this.agenda = agenda;
		this.salles = salles;
		this.surveillants = surveillants;
	}

	public Date getDateDebut() {
		return dateDebut;
	}

	public void setDateDebut(Date dateDebut) {
		this.dateDebut = dateDebut;
	}

	public Date getDateFin() {
		return dateFin;
	}

	public void setDateFin(Date dateFin) {
		this.dateFin = dateFin;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Agenda getAgenda() {
		return agenda;
	}

	public void setAgenda(Agenda agenda) {
		this.agenda = agenda;
	}

	public Set<Salle> getSalles() {
		return salles;
	}

	public void setSalles(Set<Salle> salles) {
		this.salles = salles;
	}

	public Set<Surveillant> getSurveillants() {
		return surveillants;
	}

	public void setSurveillants(Set<Surveillant> surveillants) {
		this.surveillants = surveillants;
	}

	@Override
	public String toString() {
		return "Concours [id=" + id + ", dateDebut=" + dateDebut + ", dateFin="
				+ dateFin + ", type=" + type + ", agenda=" + agenda
				+ ", salles=" + salles + ", surveillants=" + surveillants + "]";
	}

}
